package net.markos.gen;

// Generated Apr 18, 2010 6:10:43 PM by Hibernate Tools 3.3.0.GA

import static javax.persistence.GenerationType.IDENTITY;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;

/**
 * EntityB generated by hbm2java
 */
@Entity
@Table(name = "ENTITY_B", catalog = "multdb")
public class EntityB implements java.io.Serializable {

	private Long id;
	private EntityA entityA;
	private String name;
	private List<EntityC> entityCs = new ArrayList<EntityC>(0);

	public EntityB() {
	}

	public EntityB(EntityA entityA) {
		this.entityA = entityA;
	}

	public EntityB(EntityA entityA, String name, List<EntityC> entityCs) {
		this.entityA = entityA;
		this.name = name;
		this.entityCs = entityCs;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "ID", unique = true, nullable = false)
	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "ENTITY_A_ID", nullable = false)
	public EntityA getEntityA() {
		return this.entityA;
	}

	public void setEntityA(EntityA entityA) {
		this.entityA = entityA;
	}

	@Column(name = "NAME")
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "entityB")
	@OrderBy("name asc")
	public List<EntityC> getEntityCs() {
		return this.entityCs;
	}

	public void setEntityCs(List<EntityC> entityCs) {
		this.entityCs = entityCs;
	}

	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder("");
		sb.append("EntityB: ").append(name);
		for (EntityC b : entityCs) {
			sb.append("\n").append(b);
		}

		return sb.toString();
	}

}
